package com.ruoyi.charge.auth.utils;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.ServletUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HttpResonseUtils {

    /**
     * 未登录响应
     *
     * @param request
     * @param response
     */
    public static void NoLogin(HttpServletRequest request, HttpServletResponse response, String errmsg, Integer code) {
        String msg = StrUtil.format("请求访问：{}，认证失败，无法访问系统资源，原因：" + errmsg, request.getRequestURI());
        ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg)));
    }
}
